package Alee150;

import java.util.Arrays;

/**
 * ClassName: c01
 * Package: Alee150
 * Description:88. 合并两个有序数组
 *
 * @Author BCXJ
 * @Create 2025/9/22 08:47
 * @Version 1.0
 * @Since 1.0
 */
public class c01 {
    public static void main(String[] args) {

    }

    public void merge(int[] nums1, int m, int[] nums2, int n) {
        int i = 0, i1 = 0, i2 = 0;
        int[] arr = new int[m + n];
        while(i1 < m && i2 < n) {
            if(nums1[i1] < nums2[i2]) {
                arr[i] = nums1[i1];
                i1 ++;
                i ++;
            } else {
                arr[i] = nums2[i2];
                i2 ++;
                i ++;
            }
        }
        while(i1 < m) {
            arr[i] = nums1[i1];
            i ++;
            i1 ++;
        }
        while (i2 < n) {
            arr[i] = nums2[i2];
            i ++;
            i2 ++;
        }
        for (int j = 0; j < n + m; j++) {
            nums1[j] = arr[j];
        }
    }
}
